$(function () {
    $("#jqGrid").jqGrid({
        url: baseURL + 'sys/buserinfo/complainList',
        datatype: "json",
		async:false,
		colModel: [
			{ label: '用户编号', name: 'userId', index: 'user_id',align: "center", width: 50,
				formatter:function(value,options,rowData){
					return "<a  onclick='window.open(\"../sys/buserinfo.html?userId="+value+"\")'>"+value+"</a>";
				}},
			{ label: '用户名', name: 'nickName', index: 'nick_name',align: "center", width: 80 },
			{ label: '公众号标识', name: 'gzhName', index: 'gzh_code',align: "center", width: 80 },
			{ label: '文章编号', name: 'articleId', index: 'article_id',align: "center", width: 80 },
			{ label: '文章标题', name: 'articleTitle', index: 'article_title',align: "center", width: 80 },
			{ label: '举报类型', name: 'tipOffType', index: 'tip_off_type',align: "center", width: 80 ,formatter:function(value,options,rowData){
					if( value===1 ){
						return '欺诈';
					}else if( value===2 ){
						return '色情';
					}else if( value===3 ){
						return '诱导行为';
					}else if( value===4 ){
						return '不实信息';
					}else if( value===5 ){
						return '违法犯罪';
					}else if( value===6 ){
						return '骚扰';
					}else if( value===7 ){
						return '内容未经授权/滥用原创';
					}else if( value===9 ){
						return '侵权（冒充他人、侵犯名誉权）';
					}else {
						return '其他';
					}
				}},
			{ label: '举报内容', name: 'tipOffContent', index: 'tip_off_content', align: "center" ,width: 80},
			{ label: '举报图片', name: 'tipOffImgsUrl', index: 'tip_off_imgs_url',align: "center", width: 80,formatter:function(value,options,rowData){
					if( value===null ){
						return '暂无';
					}else{
						return value;
					}
				}},
			{ label: '举报发生的场景', name: 'tipOffScene',index: 'tip_off_scene',align: "center", width: 80 ,formatter:function(value,options,rowData){
					if( value===2 ){
						return '视频';
					}else{
						return '文章';
					}
				}},
			{ label: '是否已经处理', name: 'handleStatus', index: 'handle_status',align: "center", width: 80 ,formatter:function(value,options,rowData){
					var id=rowData["id"];
					if( value===1 ){
						return '已处理';
					}else{
						return "<input type=\"button\" class=\"btn btn-warning\" value='处理' onclick='vm.handle("+id+")'/>";
					}
				}},
			{ label: '创建时间', name: 'createTime', index: 'create_time',align: "center", width: 80 },
			{ label: '修改时间', name: 'modifyTime', index: 'modify_time',align: "center", width: 80 },
        ],
		viewrecords: true,
		height: "100%",
		rowNum: 8,
		rowList : [8,30,50],
        rownumbers: true, 
        rownumWidth: 25, 
        autowidth:true,
        multiselect: false,
        pager: "#jqGridPager",
        jsonReader : {
            root: "page.list",
            page: "page.currPage",
            total: "page.totalPage",
            records: "page.totalCount"
        },
		postData:{'user_id':vm.q.user_id},
        prmNames : {
            page:"page", 
            rows:"limit",
        },
        gridComplete:function(){
        	//隐藏grid底部滚动条
        	$("#jqGrid").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "hidden" }); 
        }
    });
	$.ajax({
		type: "POST",
		async:false,
		url: baseURL + 'sys/buserinfo/getUserGzhList',
		contentType: "application/json",
		success: function(r){
			if(r.code==0){
				//vm.bbrandinfo=r.brandInfo;
				$("#selectUserGzhList").append(
					"<option value=''>全部平台</option>");
				for(var i=0;i<r.userGzhList.length;i++){
					$("#selectUserGzhList").append(
						"<option value=" + r.userGzhList[i].gzhCode +">"+ r.userGzhList[i].gzhName+"</option>");
				}
			}
		}
	});
});

var vm = new Vue({
	el:'#rrapp',
	data:{
		q:{
			user_id:null,
		},
		showList: true,
		addUser: true,
		title: null,
		bUserInfo: {},
		backStatus:0,
		id:0
	},
	methods: {
		query: function () {
			vm.showList = true;
			$("#jqGrid").jqGrid('setGridParam', {
				postData: {
					'userId': vm.q.user_id,
					'gzhCode': vm.q.gzhCode
				},
				page: 1
			}).trigger("reloadGrid");
		},
		handle:function (id) {
			confirm('该信息已处理完成？', function(){
				$.ajax({
					type: "POST",
					url: baseURL + "sys/buserinfo/handle",
					contentType: "application/json",
					data: JSON.stringify(id),
					success: function(r){
						if(r.code == 0){
							alert('操作成功', function(index){
								$("#jqGrid").trigger("reloadGrid");
							});
						}else{
							alert(r.msg);
						}
					}
				});
			});
		}
	},
});
